#include "cc_ctype.h"

int cc_isalpha(int ch)
{
	return (cc_islower(ch) || cc_isupper(ch));
}

int cc_isspace(int ch)
{
	return ((ch >= 0x9 && ch <= 0xD) || ch == 0x20);
}

int cc_isblank(int ch)
{
	return (ch == '\t' || ch == ' ');
}

int cc_isdigit(int ch)
{
	return ch >= '0' && ch <='9';
}

int cc_isxdigit(int ch)
{
	return cc_isdigit(ch) || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F');
}

int cc_isalnum(int ch)
{
	return cc_isalpha(ch) || cc_isdigit(ch);
}

int cc_isupper(int ch)
{
	return ch >= 'A' && ch <= 'Z';
}

int cc_islower(int ch)
{
	return ch >= 'a' && ch <= 'z';
}

int cc_isascii(int ch)
{
	return ch >= 0 && ch <= 127;
}

int cc_ispunct(int ch)
{
	return !cc_iscntrl(ch) && !cc_isalnum(ch) && !cc_isblank(ch);
}

int cc_iscntrl(int ch)
{
	return ch <= 31 || ch == 127;
}

int cc_isprint(int ch)
{
	return !cc_iscntrl(ch);
}

int cc_isgraph(int ch)
{
	return cc_isprint(ch) && !cc_isblank(ch);
}

int cc_toascii(int ch)
{
	return ch;
}

int cc_toupper(int ch)
{
	if(cc_islower(ch)) 
		return ch - 32;

	return ch;
}

int cc_tolower(int ch)
{
	if(cc_isupper(ch)) 
		return ch + 32;

	return ch;
}